package uplb.ics.cs190.e2d.display;

import org.lwjgl.opengl.GL11;

import com.golden.gamedev.engine.lwjgl.LWJGLGraphics;

import uplb.ics.cs190.e2d.graphics.AWTImage;
import uplb.ics.cs190.e2d.graphics.Color;
import uplb.ics.cs190.e2d.graphics.Image;

public class OpenGLGraphics implements Graphics {

	protected LWJGLGraphics graphics;
	
	public OpenGLGraphics() {
		this.graphics = new LWJGLGraphics();
	}
	
	@Override
	public void setColor(Color color) {
		this.graphics.setColor(new java.awt.Color(
				color.getRed(), 
				color.getGreen(),
				color.getBlue(),
				color.getAlpha()));
	}

	@Override
	public void fillRect(int x, int y, int width, int height) {
		this.graphics.fillRect(x, y, width, height);
	}

	@Override
	public void drawImage(Image image, int x, int y) {
		GL11.glColor3f(1, 1, 1);
		this.graphics.drawImage(((AWTImage) image).getImage(), x, y, null);
	}

	@Override
	public Color getColor() {
		return new Color(
				this.graphics.getColor().getRed(),
				this.graphics.getColor().getGreen(),
				this.graphics.getColor().getBlue(),
				this.graphics.getColor().getAlpha());
	}

	@Override
	public void drawRect(int x, int y, int width, int height) {
		this.graphics.drawRect(x, y, width, height);
	}

	@Override
	public void clearRect(int x, int y, int width, int height) {
		this.graphics.clearRect(x, y, width, height);
	}

	@Override
	public void drawLine(int x1, int y1, int x2, int y2) {
		this.graphics.drawLine(x1, y1, x2, y2);
	}

	@Override
	public void drawString(String string, int x, int y) {
		this.graphics.drawString(string, x, y);
	}

}
